<template>
  <div>
    我是{{ countPrice }}
  </div>
</template>
<script>
import { ref, reactive, computed } from "vue";
export default {
  name: 'computed',
  setup() {
    const count = ref(1);
    const data = reactive({
        weight: 1,
        unit_price: 8
    });
    // let countPrice = computed(() => data.number * data.unit_price);
    let countPrice = computed({
        get: () => data.weight * data.unit_price,
        set: (val) => {
            console.log(val, "我是val");
            data.weight = val / data.unit_price;
            console.log(data.weight)
        } 
    });
    countPrice.value = 100;
    return {
        countPrice
    }
  }
}
</script>
<style scoped>

</style>